package vip.mall.modular.orderAddress.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;
import vip.mall.common.result.CommonResult;
import vip.mall.modular.orderAddress.params.AddOrderAddressParams;
import vip.mall.modular.orderAddress.service.OrderAddressService;

/**
 * @author ASUS
 * @Date 2025/2/21 22:04
 * @Descripition 订单地址模块控制器
 */
@RestController
@Tag(name = "订单地址模块控制器")
@RequestMapping("/orderAddress")
public class OrderAddressController {
    @Resource
    private OrderAddressService orderAddressService;
    @Operation(summary = "添加订单地址")
    @PostMapping("/add")
    public CommonResult addOrderAddress(@RequestBody AddOrderAddressParams addOrderAddressParams) {
        return orderAddressService.add(addOrderAddressParams)? CommonResult.success() : CommonResult.error();
    }
    @GetMapping("/delete")
    @Operation(summary = "删除订单收货地址")
    public CommonResult deleteOrderAddress(@RequestParam ("id") String id) {
        return orderAddressService.removeById(id)? CommonResult.success() : CommonResult.error();
    }
    @GetMapping("/select")
    @Operation(summary = "根据用户ID查询订单收货地址")
    public CommonResult selectOrderAddressByUserId(@RequestParam ("userId") String userId) {
        return CommonResult.success(orderAddressService.selectOrderAddressByUserId(userId));
    }
}
